<?php 
/////////////////////////////////////////////////////////////////////////////
// 这个文件是 网城创想多用户商城 项目的一部分
//
// Copyright (c) 2007 - 2008 www.shopnc.net
//
// 要查看完整的版权信息和许可信息，请查看源代码中附带的 COPYRIGHT 文件，
// 或者访问 http://www.shopnc.net/ 获得详细信息。
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : statics_product.manage.php   FILE_PATH : \system\statics_member.manage.php
 * ....会员信息统计
 *
 * @copyright Copyright (c) 2007 - 2007 www.shopnc.net 
 * @author 网城创想多用户商城开发团队 php_netproject@yahoo.com.cn
 * @package 
 * @subpackage 
 * @version Mon Dec 10 16:46:59 CST 2007
 */
require_once("../global.inc.php");

class SysStaticsMember extends SystemFrameWork{
	/**
	 * 验证对象
	 *
	 * @var obj
	 */
	var $objvalidate;
	/**
	 * 会员对象
	 *
	 * @var obj
	 */
	var $obj_member;
	/**
	 * 商品分类对象
	 *
	 * @var obj
	 */
	var $objProductCate;

	function main(){
		/**
		 * 创建商品对象
		 */
		if (!is_object($this->obj_member)){
			require_once("member.class.php");
			$this->obj_member = new MemberClass();
		}
		/**
		 * 创建验证对象
		 */
		if (!is_object($this->objvalidate)){
			require_once("commonvalidate.class.php");
			$this->objvalidate = new CommonValidate();
		}

		/**
		 * 设置模板路径
		 */
		$this->setsubtemplates("system");

		/**
		 * 语言包
		 */
		$this->getlang("product");

		switch ($this->_input['action']){
			case "list":
				$this->_liststatics();
				break;
			default:
				$this->_liststatics();
				break;
		}

	}
	/**
	 * 会员统计信息
	 *
	 */
	function _liststatics(){

		/**
		 * 取得查询参数
		 */
		$type = "d";
		$start = "2007-09-01 00:00:00";
		$end = "2007-09-30 23:59:59";
		/**
		 * 取得会员统计列表
		 */
		$member_array = $this->obj_member->getStaticsMember($type, $start, $end);
		if(is_array($member_array)){
			switch ($type) {
				case "y":
					$start = substr($start, 0, 4);
					$end = substr($end, 0, 4);
					$end_time = mktime(0, 0, 0, 1, 1, substr($end,0,4));
					$output_member_array = array();
					for($i=0; mktime(0, 0, 0, 1, 1, substr($start,0,4)+$i)<=$end_time; $i++){
						$reg_date = date("Y", mktime(0, 0, 0, 1, 1, substr($start,0,4)+$i));
						foreach ($member_array as $key => $value){
							if($reg_date == $value[reg_date]){
								$output_member_array[$i] = $member_array[$key];
								break;
							}
						}
						if($output_member_array[$i][reg_date]==""){
							$output_member_array[$i][reg_date] = $reg_date;
							$output_member_array[$i][num] = 0;
						}
					}
					break;
				case "m":
					$start = substr($start, 0, 7);
					$end = substr($end, 0, 7);
					$end_time = mktime(0, 0, 0, substr($end,5,2), 1, substr($end,0,4));
					$output_member_array = array();
					for($i=0; mktime(0, 0, 0, substr($start,5,2)+$i, 1, substr($start,0,4))<=$end_time; $i++){
						$reg_date = date("Y-m", mktime(0, 0, 0, substr($start,5,2)+$i, 1, substr($start,0,4)));
						foreach ($member_array as $key => $value){
							if($reg_date == $value[reg_date]){
								$output_member_array[$i] = $member_array[$key];
								break;
							}
						}
						if($output_member_array[$i][reg_date]==""){
							$output_member_array[$i][reg_date] = $reg_date;
							$output_member_array[$i][num] = 0;
						}
					}
					break;
				case "d":
					$start = substr($start, 0, 10);
					$end = substr($end, 0, 10);
					$end_time = mktime(0, 0, 0, substr($end,5,2), substr($end,8,2), substr($end,0,4));
					$output_member_array = array();
					for($i=0; mktime(0, 0, 0, substr($start,5,2), substr($start,8,2)+$i, substr($start,0,4))<=$end_time; $i++){
						$reg_date = date("Y-m-d", mktime(0, 0, 0, substr($start,5,2), substr($start,8,2)+$i, substr($start,0,4)));
						foreach ($member_array as $key => $value){
							if($reg_date == $value[reg_date]){
								$output_member_array[$i] = $member_array[$key];
								break;
							}
						}
						if($output_member_array[$i][reg_date]==""){
							$output_member_array[$i][reg_date] = $reg_date;
							$output_member_array[$i][num] = 0;
						}
					}
					break;
			}

		}
		/**
		 * 输出到页面模板
		 */
		$this->output("member_array", $output_member_array);
		$this->showpage("sys_statics_member.manage");
	}
}

$statics_member = new SysStaticsMember();
$statics_member->main();
unset($statics_member);
?>